#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n, m; cin >> n >> m;
    vector<int> arr(n + 1), prev(n + 1);
    for(int i = 1; i <= n; ++i) cin >> arr[i];
    for(int i = 1; i <= n; ++i) prev[i] = prev[i - 1] + arr[i];
    
    while(m--)
    {
        int l, r; cin >> l >> r;
        cout << prev[r] - prev[l - 1] << endl;
    }
    return 0;
}